package com.ruoyi.sj.service.impl;

import com.ruoyi.sj.mapper.MoneyMapper;
import com.ruoyi.sj.mapper.WithdrawMapper;
import com.ruoyi.sj.service.IChangeService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class IChangeServiceImpl implements IChangeService {

    @Autowired
    private WithdrawMapper withdrawMapper;

    @Autowired
    private MoneyMapper moneyMapper;

    @Override
    public int withDrawVerification(Long id, String status) {
        if ("1".equals(status)) {
            int i = withdrawMapper.updateWithDrawByStatus(id, status);

            /**
             * 提现到银行卡
             * description todo
             */
            BigDecimal withDrawMonry = withdrawMapper.selectMoneyById(id);
            String memberIdById = withdrawMapper.selectMemberIdById(id);
            moneyMapper.subMoney(memberIdById,withDrawMonry.toString());
            return i;

        } else {
            return withdrawMapper.updateWithDrawByStatus(id, status);
        }
    }
}
